package com.yequan.thread.threadpool.mythreadpoolmanager;

import com.yequan.thread.threadpool.plan.NamedThreadFactory;

/**
 * IO密集型线程池
 *
 * @author yequan
 * @date 2019/12/02
 */
public class IoIntensiveThreadPoolManager {

    /**
     * 线程个数
     **/
    private static int nThreads = Runtime.getRuntime().availableProcessors() * 2;
    /**
     * 实例化IOIntensiveThreadPoolManager对象
     */
    private static IoIntensiveThreadPoolManager ioIntensiveThreadPoolManager = new IoIntensiveThreadPoolManager();
    /**
     * 线程池管理对象
     */
    private CustomThreadPoolManager customThreadPoolManager;

    /**
     * 线程池构造方法
     */
    private IoIntensiveThreadPoolManager() {
        customThreadPoolManager = new CustomThreadPoolManager(4, 10000, new NamedThreadFactory("IO"));
    }

    /**
     * 获取全局唯一实例
     *
     * @return
     */
    public static IoIntensiveThreadPoolManager getInstance() {
        return ioIntensiveThreadPoolManager;
    }

    /**
     * 获取线程池管理对象
     *
     * @return
     */
    public CustomThreadPoolManager getCustomThreadPoolManager() {
        return customThreadPoolManager;
    }

}
